package other.thread;

public class MyRunnable implements Runnable{

    private int trick = 10;

    @Override
    public void run() {
        trickSell();
    }

    public synchronized void trickSell() {
        while (trick != 0 && trick >0) {
            System.out.println("线程"+Thread.currentThread()+"买票，卖出第"+trick+"张");
            trick--;
            try {
                wait(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
